interface IFormData {
  username: string;
  password: string;
  remember: boolean;
  gender: string;
}

interface IPageData {
  form: IFormData;
}

interface IPageInstance {
  data: IPageData;
  onInputChange(e: { detail: { value: string; }, currentTarget: { dataset: { field: string } } }): void;
  onCheckboxChange(e: { detail: { checked: boolean } }): void;
  onRadioChange(e: { detail: { value: string } }): void;
  onSubmit(): void;
}

Page<IPageData, IPageInstance>({
  data: {
    form: {
      username: '',
      password: '',
      remember: false,
      gender: ''
    }
  },

  onInputChange(e) {
    const { field } = e.currentTarget.dataset;
    const { value } = e.detail;
    this.setData({
      [`form.${field}`]: value
    });
  },

  onCheckboxChange(e) {
    this.setData({
      'form.remember': e.detail.checked
    });
  },

  onRadioChange(e) {
    this.setData({
      'form.gender': e.detail.value
    });
  },

  onSubmit() {
    console.log('表单数据：', this.data.form);
  }
}); 